package com.bugpool.leilema.tc.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.tree.Tree;
import com.bugpool.leilema.tc.bean.entity.SysMenu;
import com.bugpool.leilema.tc.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author wh
 * @Description
 * @Date 2023/3/1 11:10
 * @Version 1.0
 **/
@RestController
@RequestMapping("/menu")
@Api(tags = "菜单控制器")
public class MenuController {

    @Resource
    private MenuService menuService;


    @GetMapping("/treeMenu")
    @ApiOperation("获取菜单树 根据角色获取")
    @SaCheckPermission("bb")
    public List<Tree<Long>> getMenuTree(){
        return menuService.selectMenuTree();
    }

    @PutMapping("/updateMenu")
    @ApiOperation("更新菜单")
    public Boolean updateMenu(@RequestBody SysMenu sysMenu){
     return menuService.updateMenu(sysMenu);
    }

    @GetMapping("/{menuId}")
    @ApiOperation("获取详情")
    public SysMenu getSysMenu(@PathVariable Long menuId){
        return menuService.getSysMenu(menuId);
    }

    @PostMapping("/addMenu")
    @ApiOperation("新增菜单选项")
    public Boolean addMenu(@RequestBody SysMenu sysMenu){
        return menuService.addMenu(sysMenu);
    }

    @DeleteMapping("/{menuIds}")
    @ApiOperation("根据菜单id 删除")
    public boolean delByMenuIds(@PathVariable List<Long> menuIds){
        return menuService.delByMenuIds(menuIds);
    }












}
